package org.kzwl.service.app.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.kzwl.comm.advice.Consts;
import org.kzwl.comm.pojo.bo.setting.BannerQueryBO;
import org.kzwl.comm.pojo.dto.setting.BannerQueryDTO;
import org.kzwl.entity.app.Setting;
import org.kzwl.entity.web.CuCarousel;
import org.kzwl.mapper.app.SettingMapper;
import org.kzwl.mapper.web.CuCarouselMapper;
import org.kzwl.service.app.SettingService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author 张国伟/郭家恒
 * @since 2020-09-10
 */
@Service
public class SettingServiceImpl extends ServiceImpl<SettingMapper, Setting> implements SettingService {

    @Autowired
    SettingMapper settingMapper;

    @Autowired
    private CuCarouselMapper cuCarouselMapper;

    //region 条件查询
    @Override
    public List<Setting> queryBasic(List<String> settingName) {
        QueryWrapper<Setting> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().in(Setting::getCuSettingName, settingName);
        List<Setting> list = settingMapper.selectList(queryWrapper);
        return list;
    }
    //endregion

    //region 修改
    @Override
    public void updateSetting(List<Setting> data) {
        data.forEach(item -> {
            settingMapper.updateById(item);
        });
    }
    //endregion

    //region 轮播查询
    @Override
    public List<CuCarousel> bannerQuery(BannerQueryBO bo) {
        QueryWrapper<CuCarousel> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(CuCarousel::getCuTownId,0)
        .eq(CuCarousel::getCuCarouselType,bo.getQueryType());
        List<CuCarousel> cuCarousels = cuCarouselMapper.selectList(queryWrapper);
        return cuCarousels;
    }
    //endregion
}
